package com.atguigu.yygh.common.config;


import com.github.xiaoymin.knife4j.spring.annotations.EnableKnife4j;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.RequestHandler;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/*-------------------------------------------------
      时 间:   2023-03-11
      讲 师:   刘  辉
      描 述:   尚硅谷教学团队
---------------------------------------------------*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {


    @Bean
    public Docket getAdminDocket(){
       return new Docket(DocumentationType.SWAGGER_2)
               .apiInfo(getAdminInfo())
               .groupName("admin组")
               .select()
               .paths(Predicates.and(PathSelectors.regex("/admin/.*")))
               //只显示admin路径下的页面
               //.paths(PathSelectors.any())
               .build();
       // PathSelectors.regex("/admin/.*"))
    }

    private ApiInfo getAdminInfo() {
       return new ApiInfoBuilder()
               .title("管理员系统")
               .description("")
               .version("1.1")
               .contact(new Contact("","",""))
               .build();
    }

    @Bean
    public Docket getUserDocket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(getUserInfo())
                .groupName("user组")
                .select()
                //只显示admin路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/user/.*")))
                .build();
    }

    private ApiInfo getUserInfo() {
        return new ApiInfoBuilder()
                .title("用户系统")
                .description("")
                .version("1.1")
                .contact(new Contact("","",""))
                .build();
    }
    @Bean
    public Docket getApiDocket(){
        return new Docket(DocumentationType.SWAGGER_2).apiInfo(getApiInfo())
                .groupName("API组")
                .select()
                //只显示admin路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/api/.*")))
                .build();
    }

    private ApiInfo getApiInfo() {
        return new ApiInfoBuilder()
                .title("第三方医院系统")
                .description("")
                .version("1.1")
                .contact(new Contact("","",""))
                .build();
    }
}
